<?php

namespace App\Http\Controllers\Api;

use App\Constants\MiniProgramConstant;
use App\Http\Controllers\Controller as BaseController;

class Controller extends BaseController
{
    protected function getMiniType()
    {
        return request()->header('X-MINI-TYPE');
    }

    public function success($message, $data = array(), $code = 0, $status = 200)
    {
        return response()->json(['code' => $code, 'message' => $message, 'data' => $data], $status);
    }

    public function _success($data = array(), $message = '返回成功',  $code = 0, $status = 200)
    {
        return response()->json(['code' => $code, 'message' => $message, 'data' => $data], $status);
    }

    public function error($message, $data = array(), $code = -1, $status = 500)
    {
        return response()->json(['code' => $code, 'message' => $message, 'data' => $data], $status);
    }
}
